<?php
header("Content-Type:text/html;charset=utf-8");
session_start();
if(isset($_SESSION['session_key']))	$session_key=$_SESSION['session_key'];	else $session_key='';
if(isset($_GET['code']))	$code=$_GET['code'];	else $code='';
require('./conf/config.php');
require('./fun/functions.php');
require('./public/http.php');
require('./public/getcode.php');
function __autoload($class_name) {
	require_once './class/'.$class_name.'.class.php';
}
if($code){
	$userinfo=doGet();
	p($userinfo);
}elseif($session_key){
	$renren=new RenRen();
	$getAllocation=$renren->admin_getAllocation();
	$friendsget=$renren->friends_get();
	$friendsgetFriends=$renren->friends_getFriends();
	$invitations_createLink=$renren->invitations_createLink();
	$invitations_getInfo=$renren->invitations_getInfo();
	$users_getInfo=$renren->users_getInfo($renren->getLoggeduserId());
	$status_getEmoticons=$renren->status_getEmoticons();
	p($status_getEmoticons);
	foreach($invitations_createLink as $v)	echo $v.',';
	echo "<table>
		<tr><td>当前登录用户id</td><td>".$renren->getLoggeduserId()."</td></tr>
		<tr><td>一个用户当天可以发送通知的配额</td><td>".$getAllocation['notifications_per_day']."</td></tr>
		<tr><td>一个用户当天可以发送应用邀请的配额</td><td>".$getAllocation['requests_per_day']."</td></tr>
		<tr><td>得到当前登录用户的好友列表</td><td>";
	$friends='';
	foreach($friendsget as $v){
		$friends.=$v.',';
	}
	echo $friends."</td></tr>
		</table>";
	foreach($friendsgetFriends as $v){
		echo $v['id'].$v['name'].'<img src="'.$v['tinyurl'].'"/><img src="'.$v['headurl'].'"/>';
	}
}else{
	$codeUrl = getAuthorizationCode(KEY,CALLBACK_URL);
	echo '<meta http-equiv="refresh" content="0.1;url='.$codeUrl.'">';
}
?>